/*
 * GeoVISTA Center (Penn State, Dept. of Geography)
 * Copyright (c), 2003-2011,  Jin Chen and Alan M. MacEachren, GeoVISTA Center, Penn State University
 * All Rights Researved.
 *
 * This library is developed and distributed for free usage,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * You can redistribute and/or modify it under the terms of the
 * Simplified BSD License
 *
 *
 *
 *
 *
 *
 *
 *
 * @author: jin Chen 
 * @date: Aug 27, 2003$
 * @version: 1.0
 */
package edu.psu.geovista.app.pcp.toolkits.colorpalette.v1;

import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.Serializable;

public class MainSwatchPanel extends SwatchPanel {

protected void initValues() {
        swatchSize = new Dimension(15,15);//size of each color square//UIManager.getDimension("ColorChooser.swatchesSwatchSize");
	    numSwatches = new Dimension( 8, 3 );//(x,y) num of color square =x column * y row
        gap = new Dimension(3, 3);
        outlineSquare=true;
    }

    protected void initColors() {
        int[] rawValues = initRawValues();
        int numColors = rawValues.length / 3;

	colors = new Color[numColors];
	for (int i = 0; i < numColors ; i++) {
	    colors[i] = new Color( rawValues[(i*3)], rawValues[(i*3)+1], rawValues[(i*3)+2] );
	}
    }

   private int[] initRawValues() {

        int[] rawValues = {
255, 255, 255, // first row.
192, 192, 192,
255, 0, 0,
255, 255, 0,
0, 255, 0,
0, 255, 255,
0, 0, 255,
255, 0, 255,
0, 0, 0,  // second row.
128, 128, 128,
128, 0, 0,
128, 128, 0,
0, 128, 0,
0, 128, 128,
0, 0, 128,
128, 0, 128,
255, 199, 199,  // 3rd row.
83, 109, 165,
204,  255,204,
153, 153, 204,
204, 204, 214,
0, 180, 110,
252, 253, 205,
212, 133, 213,
 };
	return rawValues;
    }
   public class MainSwatchListener extends MouseAdapter implements Serializable {
        public void mousePressed(MouseEvent e) {
	    Color color = getColorForLocation(e.getX(), e.getY());
	    System.out.println("click color:"+color);
        }

	}
    
}
